// pages/environment/environment.js
Page({
  data: {
    diningEnvironment: [
      { id: 1, name: '用餐环境1', image: '/pages/images/environment1.jpg' },
      { id: 2, name: '用餐环境2', image: '/pages/images/environment2.jpg' },
      { id: 3, name: '用餐环境3', image: '/pages/images/environment3.jpg' },
      { id: 4, name: '用餐环境4', image: '/pages/images/environment4.jpg' }
    ],
    foodPictures: [
      { id: 1, name: '美食图片1', image: '/pages/images/food1.jpg' },
      { id: 2, name: '美食图片2', image: '/pages/images/food2.jpg' },
      { id: 3, name: '美食图片3', image: '/pages/images/food3.jpg' },
      { id: 4, name: '美食图片4', image: '/pages/images/food4.jpg' }
    ]
  },

  onLoad(options) {
    // 页面加载时执行
  },

  // 返回上一页
  navigateBack() {
    wx.navigateBack()
  },

  // 预览用餐环境图片
  previewDiningImage(e) {
    const current = e.currentTarget.dataset.image
    const urls = this.data.diningEnvironment.map(item => item.image)
    wx.previewImage({
      urls: urls,
      current: current
    })
  },

  // 预览美食图片
  previewFoodImage(e) {
    const current = e.currentTarget.dataset.image
    const urls = this.data.foodPictures.map(item => item.image)
    wx.previewImage({
      urls: urls,
      current: current
    })
  },

  // 分享给朋友
  onShareAppMessage() {
    return {
      title: '农家小炒 - 用餐环境与美食展示',
      path: '/pages/environment/environment',
      imageUrl: '/pages/images/share.jpg'
    }
  },

  // 分享到朋友圈
  onShareTimeline() {
    return {
      title: '农家小炒 - 用餐环境与美食展示',
      imageUrl: '/pages/images/share.jpg'
    }
  }
})